package com.learn.prometheus;

import io.micrometer.core.instrument.MeterRegistry;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.autoconfigure.metrics.MeterRegistryCustomizer;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
/**
 * Spring Boot 使用 Micrometer 集成 Prometheus 监控 Java 应用性能
 * @author:         MI
 * @email:          448341911@qq.com
 * @createTime:     2025/8/6 22:50
 * @updateUser:     MI
 * @updateTime:     2025/8/6 22:50
 * @updateRemark:   修改内容
 * @version:        1.0
 */
@SpringBootApplication
public class SpringBootPrometheusApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringBootPrometheusApplication.class, args);
    }

    @Bean
    MeterRegistryCustomizer<MeterRegistry> configurer(@Value("${spring.application.name}") String applicationName){
        return registry -> registry.config().commonTags("application", applicationName);
    }
}
